<html>
<head><meta charset="utf-8"><title>Cargo resolver in workspace · edition 2021 · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/index.html">edition 2021</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Cargo.20resolver.20in.20workspace.html">Cargo resolver in workspace</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="236170317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Cargo%20resolver%20in%20workspace/near/236170317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Cargo.20resolver.20in.20workspace.html#236170317">(Apr 26 2021 at 13:10)</a>:</h4>
<p><span class="user-mention" data-user-id="120518">@Eric Huss</span> What's the situation right now with the <code>resolver = "2"</code> default for edition 2021 in workspaces? Does a workspace automatically use resolver 2 if all members are edition 2021? Or does it need to be manually activated?</p>



<a name="236180902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Cargo%20resolver%20in%20workspace/near/236180902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Cargo.20resolver.20in.20workspace.html#236180902">(Apr 26 2021 at 14:14)</a>:</h4>
<p>In a <em>virtual</em> workspace, it needs to be manually activated. In a non-virtual workspace, it uses the edition of the top-level package. </p>
<p>Cargo currently doesn't have a way to set the default edition for a virtual workspace. That is blocked on <a href="https://github.com/rust-lang/rfcs/blob/master/text/2906-cargo-workspace-deduplicate.md">RFC 2906</a>. Someone was working on that, but it seems to have stalled. It's also a little complicated since that RFC does not have implicit defaults. There is also <a href="https://github.com/rust-lang/cargo/issues/5784">issue 5784</a> tracking this. I do not know when or if more progress will be made on RFC 2906, but I suspect it may not be stabilized for the 2021 launch. I think it can be incorporated anytime afterwards, though, since it is an explicit opt-in.</p>



<a name="236181548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Cargo%20resolver%20in%20workspace/near/236181548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Cargo.20resolver.20in.20workspace.html#236181548">(Apr 26 2021 at 14:18)</a>:</h4>
<p>I assume some automatic behaviour depending on the edition of the members couldn't work?</p>
<p>What happens with <code>cargo fix --edition</code> in a (virtual) workspace?</p>



<a name="236182238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Cargo%20resolver%20in%20workspace/near/236182238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Cargo.20resolver.20in.20workspace.html#236182238">(Apr 26 2021 at 14:22)</a>:</h4>
<p>We generally try to avoid having implicit behavior based on package member definitions. It can cause confusion when new members are added (like with path dependencies).</p>
<p><code>cargo fix --edition</code> will migrate every member to its next edition.  This won't affect the resolver, and it won't run the resolver-change notification.</p>



<a name="236182546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Cargo%20resolver%20in%20workspace/near/236182546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Cargo.20resolver.20in.20workspace.html#236182546">(Apr 26 2021 at 14:24)</a>:</h4>
<p>but running <code>cargo fix --edition</code> for a single (non-workspace) crate does upgrade the resolver? or does it add <code>resolver = "1"</code>?</p>



<a name="236185439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Cargo%20resolver%20in%20workspace/near/236185439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Cargo.20resolver.20in.20workspace.html#236185439">(Apr 26 2021 at 14:41)</a>:</h4>
<p><code>cargo fix --edition</code> doesn't modify <code>Cargo.toml</code>, so it is up to the user to make changes. The only thing <code>carog fix --edition</code> does is print some warnings if the new resolver changes the features of anything.</p>
<p>If, after running <code>fix</code>, they add <code>edition = "2021"</code>, then it will start using the new resolver.</p>



<a name="236185761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Cargo%20resolver%20in%20workspace/near/236185761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Cargo.20resolver.20in.20workspace.html#236185761">(Apr 26 2021 at 14:43)</a>:</h4>
<p>ah, right. that clarifies things. thank you</p>



<a name="236185878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/268952-edition%202021/topic/Cargo%20resolver%20in%20workspace/near/236185878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mara <a href="https://rust-lang.github.io/zulip_archive/stream/268952-edition-2021/topic/Cargo.20resolver.20in.20workspace.html#236185878">(Apr 26 2021 at 14:44)</a>:</h4>
<p>then i guess we'll just need to mention that they might want to add <code>resolver = "2"</code> in the same documentation that also explains adding <code>edition = "2021"</code> after <code>cargo fix --edition</code>.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>